/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.fiap.percistencia;

import br.com.fiap.model.DadosSAC;
import br.com.fiap.model.Entidade;
import java.util.List;
import javax.persistence.*;
import javax.servlet.ServletException;

/**
 *
 * @author rm64596
 */
public class ReclamacoesDAO {
    
    
   private EntityManagerFactory factory;
   private EntityManager motor;
   private EntityTransaction transação;

   
   public ReclamacoesDAO(){
        
        factory = Persistence.createEntityManagerFactory("sistemaWeb");
        
        
        
        
    }
   
   
   public void persistirReclamacao(Entidade reclamacao)
    {
        motor = factory.createEntityManager();
        
        transação = motor.getTransaction();
        
        transação.begin();

	motor.persist(reclamacao);

	transação.commit();
       
    }
   
   public List<DadosSAC> pesquisarReclamacoes() 
   {
	
	Query query = motor.createQuery("Select p from Reclamacoes p ");
		
	return  query.getResultList();
	} 
    
    
}
